/*
 *
 * Copyright 2018 Asylo authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

#ifndef ASYLO_CRYPTO_NONCE_GENERATOR_INTERFACE_H_
#define ASYLO_CRYPTO_NONCE_GENERATOR_INTERFACE_H_

#include <cstddef>
#include <cstdint>

#include "absl/types/span.h"
#include "asylo/util/status.h"

namespace asylo {

// NonceGeneratorInterface defines an interface for nonce-generators.
//
// Implementations of this interface must be thread-safe.
class NonceGeneratorInterface {
 public:
  NonceGeneratorInterface() = default;
  virtual ~NonceGeneratorInterface() = default;

  // Returns the size of nonces generated by this NonceGenerator.
  virtual size_t NonceSize() const = 0;

  // Generates a new nonce and writes it to |nonce|. Returns a non-OK status if
  // nonce-generation was not successful. |nonce|.size() must be greater than or
  // equal to NonceSize().
  virtual Status NextNonce(absl::Span<uint8_t> nonce) = 0;
};

}  // namespace asylo

#endif  // ASYLO_CRYPTO_NONCE_GENERATOR_INTERFACE_H_
